<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    // n*n
    // 每一次冒泡排序会选出最大的值放在数组的最后一个
  function bubbleSort(arr) {
    const len = arr.length;
    for(let i = 0;i < len;i++) {
      for(let j = 0;j < len-1-i;j++) {
        if(arr[j] > arr[j+1]) {
          [arr[j],arr[j+1]] = [arr[j+1],arr[j]]
        }
      }
    }
    return arr;
  }
  console.log(bubbleSort([1,5,7,4,6,9,10]));
  </script>
</body>
</html>